#!/bin/bash

# 资源消耗应用启动脚本

echo "正在启动资源消耗应用..."

# 检查Java版本
echo "检查Java环境..."
java -version

# 编译项目（如果需要）
if [ ! -f "target/resource-consumer-1.0.0.jar" ]; then
    echo "正在编译项目..."
    mvn clean package -DskipTests
fi

# 设置JVM参数
JVM_OPTS="-Xms512m -Xmx1024m"
JVM_OPTS="$JVM_OPTS -XX:+UseG1GC"
JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
JVM_OPTS="$JVM_OPTS -Xloggc:gc.log"

echo "JVM参数: $JVM_OPTS"

# 启动应用
echo "启动应用..."
java $JVM_OPTS -jar target/resource-consumer-1.0.0.jar

echo "应用已停止" 